package com.hertz.appr.pojo.db;

import java.util.Date;

import org.springframework.web.util.HtmlUtils;

import com.hertz.appr.service.ActionService;
import com.hertz.appr.util.Util;

/**
 * Action entity. @author MyEclipse Persistence Tools
 */

public class Action implements java.io.Serializable {

	// Fields

	/**
	 * 
	 */
	private static final long serialVersionUID = 6625616482433978175L;
	private Long id;
	private String regTid;
	private String actionTid;
	private String uid;
	private String nick;
	private String value;
	private String regText;
	private String actionText;
	private Short type;
	private Short status;
	private String provider;
	private Long startTime;
	private Long endTime;
	private Long createTime;
	private Long systemTime;
	private Answer answer;
	private String randomId;
	private Random random;
	
	public static final Short ACTION_STATUS_INIT = 0;
	public static final Short ACTION_STATUS_START = 10;
	public static final Short ACTION_STATUS_PAUSE = 20;
	public static final Short ACTION_STATUS_END = 30;
	public static final Short ACTION_STATUS_WAITDEAL = 40;
	public static final Short ACTION_STATUS_FINISH = 50;
	public static final Short ACTION_STATUS_CANCEL = 60;

	public static final Short ACTION_TYPE_GUESS = 1;
	public static final Short ACTION_TYPE_PROMOTE = 2;

	// Constructors

	/** default constructor */
	public Action() {
	}

	/** minimal constructor */
	public Action(Long id, String regTid, String uid, String nick, String value,
			String regText, Short status, Long createTime, Long systemTime) {
		this.id = id;
		this.regTid = regTid;
		this.uid = uid;
		this.nick = nick;
		this.value = value;
		this.regText = regText;
		this.status = status;
		this.createTime = createTime;
		this.systemTime = systemTime;
	}

	/** full constructor */
	public Action(Long id, String regTid, String uid, String nick, String value,
			String regText, Short status, String provider, Long startTime,
			Long endTime, Long createTime, Long systemTime) {
		this.id = id;
		this.regTid = regTid;
		this.uid = uid;
		this.nick = nick;
		this.value = value;
		this.regText = regText;
		this.status = status;
		this.provider = provider;
		this.startTime = startTime;
		this.endTime = endTime;
		this.createTime = createTime;
		this.systemTime = systemTime;
	}

	// Property accessors
	public Long getId() {
		return this.id;
	}

	public Random getRandom() {
		return random;
	}

	public void setRandom(Random random) {
		this.random = random;
	}

	public String getRandomId() {
		return randomId;
	}

	public void setRandomId(String randomId) {
		this.randomId = randomId;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public String getRegTid() {
		return this.regTid;
	}

	public void setRegTid(String regTid) {
		this.regTid = regTid;
	}

	public String getUid() {
		return this.uid;
	}

	public void setUid(String uid) {
		this.uid = uid;
	}

	public String getNick() {
		return this.nick;
	}

	public void setNick(String nick) {
		this.nick = nick;
	}

	public String getValue() {
		return this.value;
	}

	public void setValue(String value) {
		this.value = value;
	}

	public String getRegText() {
		return regText;
	}

	public String getRegTextEscape() {
		return HtmlUtils.htmlEscape(this.regText);
	}
	public void setRegText(String regText) {
		this.regText = regText;
	}

	public Short getStatus() {
		return this.status;
	}

	public void setStatus(Short status) {
		this.status = status;
	}

	public String getProvider() {
		return this.provider;
	}

	public void setProvider(String provider) {
		this.provider = provider;
	}

	public Long getStartTime() {
		return this.startTime;
	}

	public void setStartTime(Long startTime) {
		this.startTime = startTime;
	}

	public Long getEndTime() {
		return this.endTime;
	}

	public void setEndTime(Long endTime) {
		this.endTime = endTime;
	}

	public Long getCreateTime() {
		return this.createTime;
	}

	public void setCreateTime(Long createTime) {
		this.createTime = createTime;
	}

	public Long getSystemTime() {
		return this.systemTime;
	}

	public void setSystemTime(Long systemTime) {
		this.systemTime = systemTime;
	}
	
	public Short getType() {
		return type;
	}

	public void setType(Short type) {
		this.type = type;
	}
	public String getActionTid() {
		return actionTid;
	}

	public void setActionTid(String actionTid) {
		this.actionTid = actionTid;
	}

	public String getActionText() {
		return actionText;
	}
	public String getActionTextEscape() {
		return HtmlUtils.htmlEscape(actionText);
	}
	public void setActionText(String actionText) {
		this.actionText = actionText;
	}

	@Override
	public String toString(){
		return "Action{" +
		" aid=" + String.format("%1$8S", id) +
		" aidStr=" + String.format("%1$6S", ActionService.getActionId62Hex(id)) +
		" regTid=" + String.format("%1$10S", regTid) +
		" actionTid=" + String.format("%1$10S", actionTid) +
		" provider=" + String.format("%1$4S", provider) +
		" status=" + String.format("%1$2S", status) +
		", value=" + String.format("%1$-10S", value) +
		", endTime='" + this.endTime + '\'' +
        ", systemTime='" + this.systemTime + '\'' +
        ", regText='" + this.regText + '\'' +
        ", actionText='" + this.actionText + '\'' +
        '}';
	}

	public String getStartTimeStr(){
		String str = "";
		try {
			str = Util.parseDate(new Date(startTime), "yyyy-MM-dd HH:mm:ss");
		} catch (Exception e) {
			// TODO: handle exception
			e.printStackTrace();
		}
		return str;
	}
	public String getEndTimeStr(){
		String str = "";
		try {
			if(endTime != null)
				str = Util.parseDate(new Date(endTime), "yyyy-MM-dd HH:mm:ss");
		} catch (Exception e) {
			// TODO: handle exception
			e.printStackTrace();
		}
		return str;
	}
	
	public String getSystemTimeStr(){
		String str = "";
		try {
			str = Util.parseDate(new Date(systemTime), "yyyy-MM-dd HH:mm:ss");
		} catch (Exception e) {
			// TODO: handle exception
			e.printStackTrace();
		}
		return str;
	}

	public Answer getAnswer() {
		return answer;
	}

	public void setAnswer(Answer answer) {
		this.answer = answer;
	}
	
}